import Vue from 'vue'
import Router from 'vue-router'
/*
import Home from '../components/Home.vue';
import Add from '../components/Add.vue';
import Collect from '../components/Collect.vue';
import Detail from '../components/Detail.vue';
import List from '../components/List.vue';*/

Vue.use(Router)

export default new Router({
  mode:'history',//正式发布用history
  routes: [
    {
      path: '/',
      redirect: '/home'
    },//输入/的时候跳转到首页
    {path: '*', redirect: '/home'},//输入一些不认识的地址也跳转到首页
    {
      path: '/home',
      component: ()=>import('../components/Home.vue'),
      meta: {keepAlive: true,title:'首页'}//this.$toute.meta.keepAlive 不用重新加载，放在路由元信息里面
    },
    {
      path: '/add',
      component: ()=>import('../components/Add.vue'),
      meta: {title: '添加'}
    },
    {
      path: '/collect',
      component: ()=>import('../components/Collect.vue'),
      meta: {title: '购物车'}
    },
    {
      path: '/detail/:bid',
      component: ()=>import('../components/Detail.vue'),
      meta: {title: '详情'},
      name: "detail"
    },//router-link需要用name作为to的跳转目的地
    {
      path: '/list',
      component: ()=>import('../components/List.vue'),
      meta: {title: '列表'}
    }
  ]
})
